package com.yufeng.collaboration.service.impl;

import com.yufeng.collaboration.entity.Message;
import com.yufeng.collaboration.mapper.MessageMapper;
import com.yufeng.collaboration.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public List<Message> getMessagesByReceiverId(Integer receiverId) {
        return messageMapper.selectList(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<Message>().eq("receiver_id", receiverId));
    }

    @Override
    public void sendMessage(Message message) {
        messageMapper.insert(message);
    }

    @Override
    public void deleteMessage(Integer id) {
        messageMapper.deleteById(id);
    }
}
